package com.weiyan.blog.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author misterWei
 * @create 2020年01月20号:17点37分
 * @mailbox mynameisweiyan@gmail.com
 */
@Configuration
public class TokenStoreConfig {
    private static final String SIGNING_KEY = "blog";

    //使用jwt的方式
    @Bean
    public TokenStore tokenStore(){
        return new JwtTokenStore(tokenConverter());
    }

    @Bean
    public JwtAccessTokenConverter tokenConverter(){
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        jwtAccessTokenConverter.setSigningKey(SIGNING_KEY); //对称密钥
        return jwtAccessTokenConverter;

    }

}
